package com.keeping.aiimagery.handler.strategy;

import com.keeping.aiimagery.handler.ChatMsgStrategy;
import com.keeping.aiimagery.handler.InsufficientStrategy;
import org.springframework.stereotype.Component;

import javax.websocket.Session;

/**
 * 消息策略
 */
@Component
public class ChatMessageContext {

    private MessageStrategy messageStrategy;

    private Session session;

    private String userId;

    private String roomId;

    private String msg;


    public ChatMessageContext() {
    }

    public ChatMessageContext(Session session, String userId, String roomId, String msg) {
        this.session = session;
        this.userId = userId;
        this.roomId = roomId;
        this.msg = msg;

        //判断是否还有调用次数
        boolean ifUsers = true;
        if (ifUsers) {
            messageStrategy = new ChatMsgStrategy();
        } else {
            messageStrategy = new InsufficientStrategy();
        }
    }

    public void sendText() {
        messageStrategy.sendText(this.session, this.userId, this.roomId, this.msg);
    }
}
